package ead.cs.web.controller;

import ead.cs.domain.User;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class LoginController {

    private static final Logger LOGGER = Logger.getLogger(LoginController.class);

    @RequestMapping(method = RequestMethod.GET, value = "/")
    public String redirect() {
        LOGGER.info("redirect to home");
        return "home";
    }

    @RequestMapping(method = RequestMethod.GET, value = "/home")
    public String redirectHome() {
        LOGGER.info("redirect to home");
        return "home";
    }

    @RequestMapping(method = RequestMethod.GET, value = "/tracking")
    public String redirectTracking() {
        LOGGER.info("redirect to tracking");
        return "tracking";
    }

    @RequestMapping(method = RequestMethod.GET, value = "/register")
    public String redirectRegister() {
        LOGGER.info("redirect to register");
        return "register";
    }

    @RequestMapping(method = RequestMethod.POST, value = "/register")
    public String redirectRegister(User user) {
        LOGGER.info("Create account : {}" + user.getLastName());
        return "login";
    }

}
